<?php
declare(strict_types=1);

namespace App\Controller\WebApi\Common;

use App\Controller\AbstractController;
use Hyperf\HttpServer\Contract\RequestInterface;
use Hyperf\HttpServer\Annotation\RequestMapping;
use Hyperf\HttpServer\Annotation\Controller;
use App\Middleware\WebApiMiddleware;
use Hyperf\HttpServer\Annotation\Middleware;
use Service\MessageService\SmsService;
use Hyperf\Di\Annotation\Inject;

/**
 * 短信会员
 * @author chenshubo
 * @Controller(prefix="/webapi/common/sms")
 * @Middleware(WebApiMiddleware::class)
 */
class SmsController extends AbstractController
{
    /**
     * @Inject()
     * @var SmsService
     */
    protected $smsService;
    /**
     * 发送短信
     * @RequestMapping(path="sendCode", methods="post")
     */
    public function sendCode(RequestInterface $request)
    {
        return $this->smsService->sendUserSmsCode(
            (int)$request->input('cid'),
            (string)$request->input('mobile'),
            (string)$request->input('answer'),
            (string)$request->input('temp'),
            (string)$request->input('key')
            );
    }
}